﻿// -----------------------------------------------------------------------
// <copyright file="RegexTree.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace FxCopContrib.Experimental.RegexCop
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Reflection;
using System.Text.RegularExpressions;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class RegexTree : PrivateReflectionWrapper
    {
        private static readonly Assembly RegexAssembly = typeof(Regex).Assembly;
        private const string RegexTreeTypeFullName = "System.Text.RegularExpressions.RegexTree";
        private static readonly Type RegexTreeType = RegexAssembly.GetType(RegexTreeTypeFullName);

        internal RegexTree(object regexTree) : base(RegexTreeType, regexTree)
        {
        }

        internal RegexTree() : base(RegexTreeType) { }

        public RegexNode Root
        {
            get
            {
                return new RegexNode(GetFieldValue<object>("_root"));
            }
        }

        public RegexOptions RegexOptions
        {
            get
            {
                return GetFieldValue<RegexOptions>("_options");
            }
        }

        public override string ToString()
        {
            return Root.ToString();
        }
    }
}
